window.Tables=function(id,line,count=10){
    function GetWdth(e){
        let end='<div id="zy_windth_QQ464312406"></div>';
        end=$(end).css({"width":e});
        $('body').append(end);
        let ret=$('#zy_windth_QQ464312406').width();
        $('#zy_windth_QQ464312406').remove();
        return ret;
    }
    //初始化
    let w=document.body.offsetWidth;
    let h=document.body.offsetHeight;
    //计算每行个数
    this['count']=count;
    this['line']=line?line:6;
    this['id']=document.querySelector(id);
    let str='';
    for(let i=0;i<this.count*this.line;i++){
        str+='<div class="tr"></div>';
    }
    this.id.classList.add('tb-container');
    this.id.innerHTML=str;
    //绑定方法
    this.addZ=(h,l)=>{
        if(!h||!l||h>this.line){
            return false;
        }
        var js=(h-1)*this.count+l;
        var dom=this.id.querySelector('.tr:nth-of-type('+js+')');
        dom.innerHTML='<div class="td">庄</div>';
        dom.classList.add('type-z');
    };
    this.addL=(h,l)=>{
        if(!h||!l||h>this.line){
            return false;
        }
        var js=(h-1)*this.count+l;
        var dom=this.id.querySelector('.tr:nth-of-type('+js+')');
        dom.innerHTML='<div class="td">龙</div>';
        dom.classList.add('type-z');
    };
    this.rm=(h,l)=>{
        if(!h||!l||h>this.line){
            return false;
        }
        var js=(h-1)*this.count+l;
        var dom=this.id.querySelector('.tr:nth-of-type('+js+')');
        dom.removeChild(dom.querySelector('.td'));
        dom.classList.remove('type-h');
        dom.classList.remove('type-x');
        dom.classList.remove('type-z');
        dom.classList.remove('icon-zd');
        dom.classList.remove('icon-xd');
    };
    this.addX=(h,l)=>{
        if(!h||!l||h>this.line){
            return false;
        }
        var js=(h-1)*this.count+l;
        var dom=this.id.querySelector('.tr:nth-of-type('+js+')');
        dom.innerHTML='<div class="td">闲</div>';
        dom.classList.add('type-x');
    };
    this.addHu=(h,l)=>{
        if(!h||!l||h>this.line){
            return false;
        }
        var js=(h-1)*this.count+l;
        var dom=this.id.querySelector('.tr:nth-of-type('+js+')');
        dom.innerHTML='<div class="td">虎</div>';
        dom.classList.add('type-x');
    };
    this.addH=(h,l)=>{
        if(!h||!l||h>this.line){
            return false;
        }
        var js=(h-1)*this.count+l;
        var dom=this.id.querySelector('.tr:nth-of-type('+js+')');
        dom.innerHTML='<div class="td">和</div>';
        dom.classList.add('type-h');
    };
    this.addZd=(h,l)=>{
        if(!h||!l||h>this.line){
            return false;
        }
        var js=(h-1)*this.count+l;
        var dom=this.id.querySelector('.tr:nth-of-type('+js+')');
        dom.classList.add('icon-zd');
    };
    this.addXd=(h,l)=>{
        if(!h||!l||h>this.line){
            return false;
        }
        var js=(h-1)*this.count+l;
        var dom=this.id.querySelector('.tr:nth-of-type('+js+')');
        dom.classList.add('icon-xd');
    };
};